<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <title>员工档案详情</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
  <link rel="stylesheet" href="../layuimini/css/public.css" media="all">
  <style>
    body {
      background-color: #ffffff;
    }
  </style>
</head>
<body>
<div class="layui-form layuimini-form">

  <div class="layui-form-item">
    <input name="id" type="hidden" th:value="${employeeInfo.id}" >
    <label class="layui-form-label required">员工姓名</label>
    <div class="layui-input-inline">
      <input type="text" name="empName" lay-verify="required" lay-reqtext="员工姓名不能为空" placeholder="请输入员工姓名" th:value="${employeeInfo.empName}" class="layui-input">
    </div>
    <label class="layui-form-label required">民族</label>
    <div class="layui-input-inline">
      <select name="empMinZu" lay-verify="required" th:value="${employeeInfo.empMinZu}" lay-search="">
        <option value="汉族">汉族</option>
        <option value="蒙古族">蒙古族</option>
        <option value="藏族">藏族</option>
        <option value="回族">回族</option>
        <option value="维吾尔族">维吾尔族</option>
        <option value="苗族">苗族</option>
        <option value="彝族">彝族</option>
        <option value="壮族">壮族</option>
        <option value="布依族">布依族</option>
        <option value="朝鲜族">朝鲜族</option>
      </select>
    </div>
    <!--出生日期-->
    <label class="layui-form-label">出生日期</label>
    <div class="layui-input-inline">
      <input type="text" name="empBirthday" id="date" th:value="${employeeInfo.empBirthday}" disabled="disabled" placeholder="输入身份号自动获取" autocomplete="off" class="layui-input">
    </div>
  </div>

  <!--身份证号+政治面貌+婚否-->
  <div class="layui-form-item">
    <label class="layui-form-label required">身份证号</label>
    <div class="layui-input-inline">
      <input type="text" id="empCard" name="empCard" th:value="${employeeInfo.empCard}" lay-verify="required" lay-reqtext="身份证号不能为空" placeholder="请输入身份证号" value="130425200102066313" class="layui-input">
    </div>
    <label class="layui-form-label required">政治面貌</label>
    <div class="layui-input-inline">
      <select name="empMianMao" th:value="${employeeInfo.empMianMao}" lay-verify="required" lay-search="">
        <option value="群众">群众</option>
        <option value="中共党员">中共党员</option>
        <option value="共青团员">共青团员</option>
        <option value="民革党员">民革党员</option>
        <option value="民建会员">民建会员</option>
        <option value="致公党党员">致公党党员</option>
        <option value="九三学社社员">九三学社社员</option>
      </select>
    </div>
    <label class="layui-form-label required">婚否</label>
    <div class="layui-input-inline">
      <input type="radio" name="empHunYin" value="已婚" title="已婚" th:if="${employeeInfo.empHunYin=='已婚'}" checked>
      <input type="radio" name="empHunYin" value="已婚" title="已婚" th:if="${employeeInfo.empHunYin!='已婚'}">
      <input type="radio" name="empHunYin" value="未婚" title="未婚" th:if="${employeeInfo.empHunYin=='未婚'}" checked>
      <input type="radio" name="empHunYin" value="未婚" title="未婚" th:if="${employeeInfo.empHunYin!='未婚'}">
    </div>
  </div>

  <!--身份证号+政治面貌+婚否-->
  <div class="layui-form-item">
    <label class="layui-form-label required">毕业学校</label>
    <div class="layui-input-inline">
      <input type="text" name="empSchool" lay-verify="required" th:value="${employeeInfo.empSchool}" lay-reqtext="毕业学校不能为空" placeholder="请输入毕业学校" value="河北xx大学" class="layui-input">
    </div>
    <label class="layui-form-label">毕业时间</label>
    <div class="layui-input-inline">
      <input type="text" name="empBiYeTime" id="date1" th:value="${employeeInfo.empBiYeTime}" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
    </div>
    <label class="layui-form-label required">专业</label>
    <div class="layui-input-inline">
      <input type="text" name="empZhuanYe" lay-verify="required" th:value="${employeeInfo.empZhuanYe}" lay-reqtext="专业不能为空" placeholder="请输入专业" value="计算机应用" class="layui-input">
    </div>
  </div>

<!--户口地址-->
  <div class="layui-form-item">
    <label class="layui-form-label required">户口地址</label>
    <div class="layui-input-block">
      <input type="text" name="empHuKouAddress" th:value="${employeeInfo.empHuKouAddress}" lay-verify="required" lay-reqtext="户口地址不能为空" placeholder="请输入户口地址" value="河北省邯郸市大名县北峰乡前现程村" class="layui-input">
    </div>
  </div>
<!--电话-->
  <div class="layui-form-item">
    <label class="layui-form-label required">电话</label>
    <div class="layui-input-inline">
      <input type="text" name="empPhone" th:value="${employeeInfo.empPhone}" lay-verify="required" lay-reqtext="电话不能为空" placeholder="请输入电话" value="17633102707" class="layui-input">
    </div>
    <label class="layui-form-label required">学历</label>
    <div class="layui-input-inline">
      <select name="empXueLi" th:value="${employeeInfo.empXueLi}" lay-verify="required" lay-search="">
        <option value="大专">大专</option>
        <option value="本科">本科</option>
        <option value="硕士">硕士</option>
        <option value="研究生">研究生</option>
      </select>
    </div>
    <label class="layui-form-label">邮箱</label>
    <div class="layui-input-inline">
      <input type="text" name="empEmail" placeholder="请输入邮箱" th:value="${employeeInfo.empEmail}" value="2783885223@qq.com" class="layui-input">
    </div>
  </div>
  <!--家庭住址-->
  <div class="layui-form-item">
    <label class="layui-form-label required">家庭住址</label>
    <div class="layui-input-block">
      <input type="text" name="empAddress" lay-verify="required" th:value="${employeeInfo.empAddress}" lay-reqtext="家庭住址不能为空" placeholder="请输入家庭住址" value="河北省邯郸市大名县北峰乡前现城村" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item" th:if="${!employeeInfo.isJingLi()}">
    <label class="layui-form-label required">所属部门</label>
    <div class="layui-input-inline">
      <select name="departmentId" lay-verify="required" lay-search="" lay-filter="depar">
        <option th:each="d:${department}" th:value="${d.id}" th:text="${d.name }" th:if="${employeeInfo.departmentId==d.id}" selected></option>
        <option th:each="d:${department}" th:value="${d.id}" th:text="${d.name }" th:if="${employeeInfo.departmentId!=d.id}"></option>
      </select>
    </div>

    <label class="layui-form-label required">职务</label>
    <div class="layui-input-inline">
      <select name="roleId" id="roleid" lay-verify="required" th:value="${employeeInfo.roleId}" lay-search="">
        <option th:each="d:${roles}" th:value="${d.id}" th:text="${d.description}" th:if="${employeeInfo.roleId==d.id}" selected></option>
        <option th:each="d:${roles}" th:value="${d.id}" th:text="${d.description}" th:if="${employeeInfo.roleId!=d.id}"></option>
      </select>
    </div>
  </div>

  <!--身份证号+政治面貌+婚否-->
  <div class="layui-form-item">
    <label class="layui-form-label required">入职日期</label>
    <div class="layui-input-inline">
      <input type="text" name="empRuZhiDate" th:value="${employeeInfo.empRuZhiDate}" id="date2" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
    </div>
    <label class="layui-form-label">转正日期</label>
    <div class="layui-input-inline">
      <input type="text" name="empZhuanZhengDate" th:value="${employeeInfo.empZhuanZhengDate}" id="date3" placeholder="yyyy-MM-dd" class="layui-input">
    </div>
    <label class="layui-form-label">离职日期</label>
    <div class="layui-input-inline">
      <input type="text" name="empLiZhiDate" id="date4" th:value="${employeeInfo.empLiZhiDate}" placeholder="yyyy-MM-dd" class="layui-input">
    </div>
  </div>

  <!--性别选择-->
  <div class="layui-form-item">
    <label class="layui-form-label">性别</label>
    <div class="layui-input-inline">
      <input type="radio" name="empSex" value="1" title="男" th:if="${employeeInfo.empSex==1}" checked>
      <input type="radio" name="empSex" value="1" title="男" th:if="${employeeInfo.empSex!=1}">
      <input type="radio" name="empSex" value="2" title="女" th:if="${employeeInfo.empSex==2}" checked>
      <input type="radio" name="empSex" value="2" title="女" th:if="${employeeInfo.empSex!=2}">
    </div>
    <label class="layui-form-label">签署合同</label>
    <div class="layui-input-inline" th:each="c:${conList}">
      <input type="checkbox" th:value="${c.id}" th:title="${c.contractName }" lay-skin="primary" checked="checked" disabled>
    </div>
    <label class="layui-form-label required">签署时长</label>
    <div class="layui-input-inline">
      <select name="conTime" th:value="${conInfoList[0].year}" lay-verify="required" lay-search="" disabled>
        <option value="0.5" th:if="${conInfoList[0].year==0.5}" selected>半年</option>
        <option value="0.5" th:if="${conInfoList[0].year!=0.5}">半年</option>
        <option value="1" th:if="${conInfoList[0].year==1}" selected>一年</option>
        <option value="1" th:if="${conInfoList[0].year!=1}">一年</option>
        <option value="3" th:if="${conInfoList[0].year==3}" selected>三年</option>
        <option value="3" th:if="${conInfoList[0].year!=3}">三年</option>
        <option value="5" th:if="${conInfoList[0].year==5}" selected>五年</option>
        <option value="5" th:if="${conInfoList[0].year!=5}">五年</option>
      </select>
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
    </div>
  </div>
</div>
<script src="../layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
  layui.use(['form', 'layedit', 'laydate'], function () {
    var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , $ = layui.$;


    form.on('select(depar)',function(){
      let id=$(":input[name='departmentId']").val();
      $.ajax({
        url:"/demand/ajaxone?id="+id,
        type:"post",
        async:false,
        success:function (data){
          $("#roleid").empty();
          for (let i = 0; i < data.roles.length; i++) {
            $("#roleid").append(
                    "<option value="+data.roles[i].id+">"+data.roles[i].description+"</option>"
            );
          }
          form.render('select');
        }
      });
    });

    //日期
    laydate.render({
      elem: '#date'
    });
    laydate.render({
      elem: '#date1'
    });
    laydate.render({
      elem: '#date2'
    });
    laydate.render({
      elem: '#date3'
    });
    laydate.render({
      elem: '#date4'
    });

    /*身份证号框子弹起*/
    $("#empCard").blur(function() {
      let card = $(this).val();
      if(card.length>18||card.length < 18){
        layer.msg("身份证长度错误！")
      }else {
        let year = card.substring(6,10);
        let month = card.substring(10,12);
        let date = card.substring(12,14);
        $("#date").val(year+"-"+month+"-"+date)
      }
    });

    //监听提交
    form.on('submit(saveBtn)', function (data) {
      $.post('/user/edit',data.field,function(res){
        if(res.data==="success"){
          var iframeIndex = parent.layer.getFrameIndex(window.name);
          parent.layer.close(iframeIndex);
          //通过父页面去重新加载表格
          parent.layui.table.reload('table-user');
          parent.layer.msg(res.msg);
        }
      });
      var iframeIndex = parent.layer.getFrameIndex(window.name);
      parent.layer.close(iframeIndex);
      return false;
    });
  });
</script>
</body>
</html>